import request from '@/utils/request';
import type { cate ,tAddAttrParam} from './model/index';
enum API {
  reqCategory1List = '/admin/product/getCategory1',
  reqCategory2List = '/admin/product/getCategory2/',
  reqCategory3List = '/admin/product/getCategory3/',
  reqAttrInfoList = '/admin/product/attrInfoList/',
  reqAttrAddOrUpdate = '/admin/product/saveAttrInfo',
  reqAttrDel = '/admin/product/deleteAttr/'
}

export const reqCategory1List = () => {
  return request.get<any, cate[]>(API.reqCategory1List);
};
export const reqCategory2List = (id: number | string) => {
  return request.get<any, cate[]>(API.reqCategory2List + id);
};
export const reqCategory3List = (id: number | string) => {
  return request.get<any, cate[]>(API.reqCategory3List + id);
};

// GET /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id}

export const reqAttrInfoList = (
  category1Id: number | string,
  category2Id: number | string,
  category3Id: number | string
) => {
  return request.get<any, tAddAttrParam[]>(
    API.reqAttrInfoList + `${category1Id}/${category2Id}/${category3Id}`
  );
};

// POST   /admin/product/saveAttrInfo
export const reqAttrAddOrUpdate = (data: tAddAttrParam) => {
  return request.post<any,any>(API.reqAttrAddOrUpdate, data);
};


// DELETE /admin/product/deleteAttr/{attrId}
export const reqAttrDel =(attrId:number|string)=>{
   return request.delete(API.reqAttrDel+attrId)
}
